package com.zuohuaipan.headine.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zuohuaipan.headine.R;

/**
 * Created by ASUS on 2017/1/6.
 */

public class My_list_Adapter extends BaseAdapter {

    String[] str = new String[]{"消息通知", "活动", "头条商城", "京东特供", "我要爆料", "用户反馈"};


    Context context;
    private ViewHolder vh;

    public My_list_Adapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return str.length;
    }

    @Override
    public Object getItem(int position) {
        return str[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.list_item, null);
            vh = new ViewHolder();
            vh.item_text = (TextView) convertView.findViewById(R.id.item_text);
            convertView.setTag(vh);

        } else {
            vh = (ViewHolder) convertView.getTag();
        }
        //赋值
        vh.item_text.setText(str[position]);


        return convertView;
    }

    class ViewHolder {
        TextView item_text;
    }
}
